#ifndef UDPCOM_H
#define UDPCOM_H
#include <QUdpSocket>

#define DEFAULTPORT 8080

typedef struct {
    QString localIP;
    quint16 localPort;
} UdpSetStruct;

//enum UdpError {UDPError1,UDPError2};
class CMyUdp:public QObject
{
Q_OBJECT
public:
   CMyUdp();
   ~CMyUdp();
private:
   bool m_flagConnected;
   UdpSetStruct mSet;
   QUdpSocket *udpSocket;
public:
   void SetParam(UdpSetStruct setInfo);
   bool OpenUdp();
   void CloseUdp();
   int SendData(const char * data, int size, QString address, quint16 port );
   bool IsConnected();
   UdpSetStruct GetUdpSet();

private slots:
   void readPendingDatagrams();
signals:
   void UdpRecv(const char * data, quint64 maxSize,
                QString address , quint16 port);
   void UdpRecv(const char *data, quint64 maxSize);
};

#endif // UDPCOM_H
